<template>
    <el-form-item> 
    <el-button type="primary" @click="createDialogVisible = true" style="background-color: rgb(37, 108, 155);">添加</el-button>
    <el-dialog title="创建问题日志" :visible.sync="createDialogVisible">
      <el-form ref="formCreate" :model="formCreate" label-width="80px">
        <el-form-item label="问题标题" style=" display: block;">
        <el-input v-model="formCreate.name"></el-input>
        </el-form-item>
        <el-form-item label="班组">
        <el-select v-model="formCreate.region_name" placeholder="请选择班组">
          <el-option label="调度组" value="调度组"></el-option>
          <el-option label="库房组" value="库房组"></el-option>
          <el-option label="产线技术组" value="产线技术组"></el-option>
          <el-option label="数控一组" value="数控一组"></el-option>
          <el-option label="数控二组" value="数控二组"></el-option>
          <el-option label="数控三组" value="数控三组"></el-option>
         </el-select>
        </el-form-item>
        <el-form-item label="上报时间">
        <el-date-picker type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="formCreate.date" style="width: 100%;"></el-date-picker>
        </el-form-item>
        <el-form-item label="问题分类" style=" display: block;">
          <template>
            <el-radio v-model="formCreate.problem_type" label="信息化异常">信息化异常</el-radio>
            <el-radio v-model="formCreate.problem_type" label="生产协调">生产协调</el-radio>
          </template>
        </el-form-item>
        <el-form-item label="问题描述" style=" display: block;">
          <el-input type="textarea" v-model="formCreate.description" style="width: 500px;"></el-input>
        </el-form-item>
        <el-form-item label="解决思路" style=" display: block;">
          <el-input type="textarea" v-model="formCreate.solution" style="width: 500px;"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="createDialogVisible = false" style="background-color: rgb(37, 108, 155);">取 消</el-button>
        <el-button type="primary" @click="emitCreate" style="background-color: rgb(37, 108, 155);">提交</el-button>
      </div>
    </el-dialog>
  </el-form-item>
</template>
<script>
export default{
  props:{
    tableData: {
            type: Array,
            required: true
        }
  },
    data(){
        return {
            createDialogVisible: false,
            formCreate: {
                name: '',
                region_name:'',
                date:null,
                problem_type:[],
                description: '',
                solution: ''
            },
        }
    },
    methods:{
        emitCreate() {
            console.log("发送创建事件给父组件");
            const createdItem = {
              name: this.formCreate.name,
              region_name: this.formCreate.region_name,
              date: this.formCreate.date,
              problem_type:this.formCreate.problem_type,
              solution: this.formCreate.solution,
              description:this.formCreate.description,
              is_solved: false,
              updatetime:null
          };
            this.$emit('handleCreateEvent', createdItem);
            this.createDialogVisible = false;
            console.log(this.formCreate.date)
          },
  }
}
</script>
